package com.molichuxing.services.property;


public enum CarsStockTypeEnum {

	/**
	 * 中转库
	 */
	STOCK(1, "中转库"),
	/**
	 * 门店
	 */
	STORE(2, "门店");


	int value;
	String name;

	CarsStockTypeEnum(int value, String name) {
		this.value = value;
		this.name = name;
	}

	public int getValue() {
		return value;
	}

	public String getName() {
		return name;
	}


	/**
	 * 通过value获取枚举的name
	 * 
	 * @param value
	 * @return
	 */
	public static String getName(int value) {
		CarsStockTypeEnum enumerate = getEnum(value);
		return enumerate == null ? null : enumerate.getName();
	}

	/**
	 * 通过value获取枚举
	 * 
	 * @param value
	 * @return
	 */
	public static CarsStockTypeEnum getEnum(int value) {
		for (CarsStockTypeEnum enumerate : CarsStockTypeEnum.values()) {
			if (enumerate.getValue() == value) {
				return enumerate;
			}
		}
		return null;
	}


	/**
	 * 通过name获取枚举
	 *
	 * @param name
	 * @return
	 */
	public static CarsStockTypeEnum getEnum(String name) {
		for (CarsStockTypeEnum enumerate : CarsStockTypeEnum.values()) {
			if (enumerate.getName().equals(name)) {
				return enumerate;
			}
		}
		return null;
	}
}
